#include "bsw_epoll.h"
#include <errno.h>
#include <unistd.h>
#include <sys/epoll.h>

static int epfd;

static int epoll_init(int size)
{
    epfd = epoll_create(size);
    return epfd > 0 ? 0 : errno;
}

static void epoll_close(void)
{
    if (epfd > 0)
        close(epfd);
    return ;
}

static int epoll_add(struct event *eve)
{
    return 0;
}

static int epoll_del(struct event *eve)
{
    return 0;
}

static int epoll_mod(struct event *eve)
{
    return 0;
}

static int epoll_enque(struct event_queue *q)
{
    // epoll_wait
    // enque event
    return 0;
}

static struct event_action event_action_epoll = {
    .init = epoll_init,
    .add  = epoll_add,
    .del  = epoll_del,
    .mod  = epoll_mod,
    .enque = epoll_enque,
    .close = epoll_close
};

#if 0
#endif
void bsw_event_action_set(struct event_ctx *ctx)
{
    ctx->action = event_action_epoll;
    return ;
}